package cn.jiyun.utils;

import org.apache.kafka.clients.consumer.ConsumerRecord;

import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import java.util.Optional;

/**
 * @Author weiyuanhang
 * @data: 2023/9/10 001020:16
 * @Package cn.jiyun.listener
 * @email 3185757326@qq.com
 */
@Component
public class HelloListener {
    @KafkaListener(topics = {"kafka-hello"})
    public void receiverMessage(ConsumerRecord<?,?> record){
        Optional<? extends ConsumerRecord<?, ?>> optional = Optional.ofNullable(record);
        if(optional.isPresent()){
            Object value = record.value();
            System.out.println(value);
        }
    }
}
